$(function(){
	$("#saveSendeeInfo").click(function(){
		var sendeeName = $("#sendeeName").val();
		if(!sendeeName){
			eDialog.alert('请填写姓名');
			return;
		}
		var phoneNume = $("#phoneNume").val();
		if(!phoneNume){
			eDialog.alert('请填写号码');
			return;
		}
		if(phoneNume.length!=11){
			eDialog.alert('请填写正确的手机号码');
			return;
		}
		var  groupId = "";
		$("input[name='group']").each(function(){
			if($(this).get(0).checked){
				var ele = $(this).get(0);
				groupId+=$(ele).val()+",";
			}
		});
		$.ajax({
			url: GLOBAL.WEBROOT+"/sendeeInfo/saveSendeeInfo",
	        data:{
	        	sendeeName:sendeeName,
	        	phoneNume:phoneNume,
	        	groupId:groupId,
	        	remark:$("#remark").val()
	        },
	        type:"post",
	        dataType:"json",
	        async:true,
		    cache:true,
	        success: function (data){
	        	window.top.location.href =WEB_ROOT+"/sendeeInfo/init";
	        },
	        error:function(XMLHttpRequest, textStatus, errorThrown){
	        	
	        }
		});
	});
	$("#groupNumInput").click(function(){
		var groupNum = $("#groupNum").val();
		if(groupNum){
			var  groupId = "";
			$("input[name='group']").each(function(){
				if($(this).get(0).checked){
					var ele = $(this).get(0);
					groupId+=$(ele).val()+",";
				}
			});
			
			var url = GLOBAL.WEBROOT+"/sendeeInfo/ExcelImportProcess?groupId="+groupId;
			$.ajaxFileUpload({
				url :url ,
				secureuri : false,
				fileElementId : 'groupNum',
				type : 'POST',
				dataType : 'text', //or json xml whatever you like~
				success : function(data, status) {
					window.top.location.href =WEB_ROOT+"/sendeeInfo/init";
				},
				error : function(data, status, e) {
					//$("#result").append(data);
					console.log("error");
				}
			});
		}else{
			eDialog.alert('请先选择文件');
			return;
		}
	});
});